import Mock from 'mockjs'
const top = [{
    'label': '工作台',
    'path': '/wel/index',
    'icon': 'iconfont icon-gongzuotai',
    'meta': {
        'i18n': 'workbench'
    },
    'parentId': 0
},
{
    'label': '贷前管理',
    'icon': 'iconfont icon-luru',
    'meta': {
        'i18n': 'pre-loan'
    },
    'path': '',
    'parentId': 1
},
{
    'label': '贷中管理',
    'icon': 'iconfont icon-daizhongguanli',
    'path': '',
    'meta': {
        'i18n': 'in-loan'
    },
    'parentId': 2
},
{
    'label': '贷后管理',
    'icon': 'iconfont icon-bianzu',
    'path': '',
    'meta': {
        'i18n': 'after-loan'
    },
    'parentId': 3
},
{
    'label': '信息中心',
    'icon': 'iconfont icon-zhongxin',
    'path': '',
    'meta': {
        'i18n': 'information'
    },
    'parentId':4
},
{
    'label': '系统管理',
    'icon': 'iconfont icon-system',
    'path': '',
    'meta': {
        'i18n': 'system'
    },
    'parentId': 5
}];
const first = [{
    'label': '发起流程',
    'path': '/error',
    'meta': {
        'i18n': 'error'
    },
    'icon': 'iconfont icon-bianzu1',
    'children': [{
        'label': '车贷流程',
        'path': 'error',
        'component': 'components/error-page/403',
        'icon': 'icon-caidan',
        'children': []
    }, {
        'label': '404',
        'path': '404',
        'component': 'components/error-page/404',
        'icon': 'icon-caidan',
        'children': []
    }, {
        'label': '500',
        'path': '500',
        'component': 'components/error-page/500',
        'icon': 'icon-caidan',
        'children': []
    }]
},{
    'label': '缓冲',
    'path': '/cache',
    'component': 'views/util/cache',
    'icon': 'icon-caidan',
    'meta': {
        'i18n': 'cache',
        'keepAlive': true
    },
    'children': []
}, {
    'label': '标签',
    'path': '/tags',
    'component': 'views/util/tags',
    'icon': 'icon-caidan',
    'meta': {
        'i18n': 'tags'
    },
    'children': []
}]
const second = []
const third = []
const fourth = []
const fifth = []
const sixth = [{
    'label': '单位管理',
    'path': '/company',
    'icon': 'el-icon-office-building',
    'children': [{
        'label': '单位管理',
        'path': 'index',
        'component': 'views/system/company/company',
        'icon': 'iconfont icon-xingzhuang',
        'children': [],
        'meta': {
            'keepAlive': false
        }
    },{
        'label': '组织架构',
        'path': 'orgtree',
        'component': 'views/system/company/org_tree',
        'icon': 'iconfont icon-zuzhijiagou',
        'children': [],
        'meta': {
            'keepAlive': false
        }
    },{
        'label': '用户管理',
        'path': 'user',
        'component': 'views/system/company/user',
        'icon': 'el-icon-user',
        'children': [],
        'meta': {
            'keepAlive': false
        }
    },{
        'label': '权限角色管理',
        'path': 'role',
        'component': 'views/system/company/role',
        'icon': 'iconfont icon-user_role',
        'children': [],
        'meta': {
            'keepAlive': false
        }
    },{
        'label': '单位架构一览',
        'path': 'orglist',
        'component': 'views/system/company/org_list',
        'icon': 'iconfont icon-xiangmuyilanbiao',
        'children': [],
        'meta': {
            'keepAlive': false
        }
    }]
},{
    'label': '视图管理',
    'path': '/view',
    'menuId':'1001',
    'meta': {
        'i18n': 'view'
    },
    'icon': 'iconfont icon-biaodan',
    'children': [{
        'label': '视图配置',
        'path': 'index',
        'component': 'views/system/view',
        'icon': 'iconfont icon-viewpeizhi',
        'children': [],
        'menuId':'1001001',
        'meta': {
            'keepAlive': false
        }
    }]
}]

export default ({ mock }) => {
    if (!mock) {
        return
    }
    let menu = [first, second, third,fourth,fifth,sixth];

    Mock.mock('/user/getMenu', 'get', (res) => {
        let body = JSON.parse(res.body);

        return {
            data: menu[body.type] || []
        }
    })
    Mock.mock('/user/getTopMenu', 'get', () => {
        return {
            data: top
        }
    })

}